package com.cloudkinto.service.order.input;

import com.baomidou.mybatisplus.extension.service.IService;
import com.cloudkinto.bo.api.InputUpdateStatusBo;
import com.cloudkinto.bo.api.NormalReceiptAndShelfApiBo;
import com.cloudkinto.bo.api.NormalReceiptAndShelfBySkuApiBo;
import com.cloudkinto.bo.api.NormalReceiptAndShelfDetailSkuApiBo;
import com.cloudkinto.bo.order.inbound.*;
import com.cloudkinto.common.web.PageResult;
import com.cloudkinto.common.web.SingleResult;
import com.cloudkinto.dto.order.inbound.OrderInputProductTransitDto;
import com.cloudkinto.entity.*;
import com.cloudkinto.vo.common.CommonBatchOperationVo;
import com.cloudkinto.vo.order.inbound.OrderInputAcceptGoodsOrderDetailVo;
import com.cloudkinto.vo.order.inbound.OrderInputDetailVo;
import com.cloudkinto.vo.order.inbound.OrderScanResultVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 到货通知单（订单入库） service接口
 * </p>
 *
 * @author long
 * @since 2024-11-04
 */
public interface OrderInputService extends IService<OrderInputDo> {

    List<OrderInputProductTransitDto> getTransitProductList(@Param("map") Map<String, Object> map);

    /**
     * 保存提交/草稿、编辑
     */
    void save(OrderInputSaveBo bo, Long userId, String username, Long tenantId, Long companyId);

    /**
     * 列表提交按钮
     */
    void submit(Long id, Long currentUserId, String userName);

    OrderInputDetailVo detail(Long id);

    SingleResult pageInit(Long companyId, Long tenantId, String source, Long userId);

    /**
     * 入库单列表
     */
    PageResult getListPage(OrderInputQueryBo bo);


    PageResult getListPageApi(OrderInputQueryBo bo);

    /**
     * 修改预期日期
     */
    void updateExpectedDate(Long id, String expectedDate, Long userId, String username);

    /**
     * 到仓扫描
     */
    List<OrderScanResultVo> scan(String condition, Long whId, Long tenantId);

    /**
     * 入库单收货入库产品分页查询
     */
    PageResult acceptGoodsListPage(AcceptGoodsQueryBo bo);

    /**
     * 入库单收货基本数据查询（不包括产品信息的订单信息）
     */
    OrderInputAcceptGoodsOrderDetailVo acceptGoodsDetail(AcceptGoodsDetailQueryBo bo);

    /**
     * 收货前置
     */
    SingleResult acceptGoodsDetailInit();

    /**
     * 整单接收
     *
     * @param id 入库单id
     * @return
     */
    String receiptTotalById(Long id, Long userId, String username);

    /**
     * 整单收货并创建上架单
     *
     * @return 上架单号
     */
    String receiptTotalHandler(Long id, Long userId, String username, OrderInputDo orderInputDo);

    /**
     * 收货确认（常规入库）
     *
     * @return 该订单是否完全收货
     */
    boolean normalReceiptConfirm(NormalReceiptConfirmBo bo, Long userId, String username);

    void normalReceiptAndShelfApi(NormalReceiptAndShelfApiBo bo, Long userId, String username);

    void normalReceiptAndShelfBySkuApi(NormalReceiptAndShelfBySkuApiBo bo, Long userId, String username);

    void apiShelfHandler(Long userId, String username, OrderInputDo inputDo, OrderInputShelfDo shelfDo, List<NormalReceiptAndShelfDetailSkuApiBo> skuApiBoList);

    /**
     * 收货确认（备货中转）
     *
     * @return 该订单是否完全收货
     */
    boolean transferReceiptConfirm(TransferReceiptConfirmBo bo, Long currentUserId, String userName);


    /**
     * 修改托盘数
     */
    void updatePalletQty(Long id, Integer palletQty, Long currentUserId, String userName);

    SingleResult getListPageStatus(OrderInputQueryBo bo);

    void excelExport(OrderInputQueryBo bo, Long tenantId, Long companyId, Long whId, HttpServletResponse response) throws IOException;


    void exportSkuLabel(SkuCodePrintPdfBo bo, HttpServletResponse response) throws IOException;

    void printPackageLabelPdf(PackageLabelPrintPdfBo bo, HttpServletResponse response);

    void printReceivingNote(Long id, HttpServletResponse response) throws IOException;

    void printReceivingNoteBoxBarcode(Long id, HttpServletResponse response) throws IOException;

    void printReceivingNoteSku(Long id, Long whId, HttpServletResponse response) throws IOException;

    void submitBatch(InboundSubmitBo bo, Long userId, String username);

    CommonBatchOperationVo cancel(InboundCancelBo bo, Long userId, String username);

    void getNormalInboundImportTemplate(HttpServletResponse response, Long tenantId, Long userId, Long companyId, String source) throws IOException;

    void getTransferInboundImportTemplate(HttpServletResponse response, Long tenantId, Long userId, Long companyId, String source) throws IOException;

    CommonBatchOperationVo importNormalInbound(MultipartFile file, Long tenantId, Long userId, String username);

    CommonBatchOperationVo importTransferInbound(MultipartFile file, Long tenantId, Long userId, String username);

    SingleResult updateTrackingNumber(InboundUpdateTrackingNumberBo bo, Long userId, String username);

    void forceEnd(Long id, Long userId, String username);

    SingleResult<CommonBatchOperationVo> postToJdyInputOrder(InboundPostToJdyBo bo);

    String proxyWarehousePushToJdy(OrderInputDo inputDo, List<OrderBoxDo> boxList, Map<String, List<OrderBoxProductDo>> boxMarkNoMatchList, Map<String, List<OrderBoxProductDo>> boxTypeNoMatchList, Map<Long, ProductDo> productIdMatchDo);

    List<String> batchUpdateInputStatus(InputUpdateStatusBo bo, Long whId, Long userId, String username);

    Map<String, Boolean> judgeUpdateBoxProductInfo(JudgeUpdateBoxProductInfoBo bo);
}
